import java.util.*;

/**
 * @Author 12629
 * @Date 2022/3/9 21:26
 * @Description：
 */
public class TestDemo4 {

    public static void main(String[] args) {
        ArrayList<Integer> arrayList1 = new ArrayList<>();
        arrayList1.add(1);
        arrayList1.add(2);
        arrayList1.add(3);

        for (int i = 0; i < arrayList1.size(); i++) {
            System.out.println(arrayList1.get(i));
        }
        System.out.println("==============");
        for(Integer x :arrayList1) {
            System.out.println(x);
        }
        System.out.println("==============");
        //迭代器
        Iterator<Integer> iterator = arrayList1.listIterator();
        while (iterator.hasNext()) {
            System.out.print(iterator.next()+" -> ");
        }

    }

    public static void main3(String[] args) {
        ArrayList<Integer> arrayList1 = new ArrayList<>();
        arrayList1.add(1);
        arrayList1.add(1,10);
        //arrayList1.remove(new Integer(10));

        arrayList1.clear();
        System.out.println(arrayList1);

//        int ret = arrayList1.get(0);
//        System.out.println(ret);

    }

    public static void main2(String[] args) {
        ArrayList<Integer> arrayList1 = new ArrayList<>();

        ArrayList<Integer> arrayList2 = new ArrayList<>(15);


        Collection<Integer> collection = new LinkedList<>();
        collection.add(1);
        collection.add(2);
        collection.add(3);
        ArrayList<Integer> arrayList3 = new ArrayList<>(collection);

        System.out.println(arrayList3);

        //迭代器
        Iterator<Integer> iterator = arrayList3.iterator();
        while (iterator.hasNext()) {
            System.out.print(iterator.next()+" -> ");
        }
    }

    public static void func(List<Integer> list) {

    }


    public static void main1(String[] args) {
        List<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);

        ArrayList<Integer> arrayList = new ArrayList<>();
        List<Integer> list2 = new LinkedList<>();
        List<Integer> list3 = new Stack<>();

        func(list2);
        func(list);
        func(list3);
        func(arrayList);
    }
}
